home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Complete Linux
/
Complete Linux.iso
/
xwindows
/
devel
/
whatvga.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-05-13
|
19KB
|
860 lines
uses dos,crt;
type
str10=string[10];
const
mems:array[0..7] of string[5]=('64 K','128 K','192 K','256 K','512 K','768 K','1 M','2 M');
mmmask :array[0..7] of byte=(0,0,0,0,1,3,3,7);
mmbanks:array[0..7] of byte=(1,2,3,4,8,12,16,32);
_64 =0;
_128 =1;
_192 =2;
_256 =3;
_512 =4;
_768 =5;
_1024=6;
_2048=7;
hx:array[0..15] of char='0123456789ABCDEF';
type
CHIPS=(__EGA,__VGA,__chips451,__chips452,__chips453,__paradise,__video7
,__tseng3,__tseng4,__tridBR,__tridCS,__trid89,__everex,__ati1,__ati2
,__genoa,__oak,__cirrus,__aheadA,__aheadB,__ncr,__yamaha,__poach
,__vesa,__none);
var
rp:registers;
mm:byte; {in 64k blocks}
name:string[40];
base,old,curbank,x:word;
CHIP:CHIPS;
video:string[5];
_crt:string[20];
secondary:string[20];
extra:string[80];
bytes:longint;
ix17,lins,vseg,vgran:word;
function istr(w:word):str10;
var s:str10;
begin
str(w,s);
istr:=s;
end;
procedure vio(ax:word);
begin
rp.ax:=ax;
intr(16,rp);
end;
function rdinx(pt,inx:word):word; {read register PT index INX}
begin
port[pt]:=inx;
rdinx:=port[pt+1];
end;
procedure wrinx(pt,inx,val:word); {write VAL to register PT index INX}
begin
port[pt] :=inx;
port[pt+1]:=val;
end;
procedure modinx(pt,inx,mask,nwv:word);
begin
port[pt]:=inx;
port[pt+1]:=(port[pt+1] and not mask)+(nwv and mask);
end;
procedure setchip23(bank:word);
begin
if chip=__chips452 then bank:=bank shl 2 else bank:=bank shl 4;
wrinx(base+2,16,bank);
{ wrinx(base+2,17,bank);}
end;
procedure setbank(bank:word);
var x:word;
begin
vseg:=$a000;
if odd(port[$3cc]) then base:=$3d4 else base:=$3b4;
case chip of
__chips451:wrinx(base+2,11,bank);
__chips452:wrinx(base+2,16,bank shl 2);
__chips453:wrinx(base+2,16,bank shl 4);
__paradise:wrinx($3ce,9,bank shl 4);
__video7:begin
x:=port[$3cc] and $df;
if (bank and 2)>0 then inc(x,32);
port[$3c2]:=x;
modinx($3c4,$f9,1,bank);
modinx($3c4,$f6,$80,(bank shr 2)*5);
end;
__tseng3:port[$3cd]:=bank*9+64;
__tseng4:port[$3cd]:=bank*17;
__tridBR:;
__tridCS,__poach,__trid89
:begin
wrinx($3c4,11,0);
if rdinx($3c4,11)=0 then;
modinx($3c4,14,$f,bank xor 2);
end;
__everex:begin
x:=port[$3cc] and $df;
if (bank and 2)>0 then inc(x,32);
port[$3c2]:=x;
modinx($3c4,8,$80,bank shl 7);
end;
__ati1:modinx($1ce,$b2,$1e,bank shl 1);
__ati2:modinx($1ce,$b2,$ee,bank*$22);
__genoa:wrinx($3c4,6,bank*9+64);
__oak:wrinx($3de,17,bank*17);
__aheadA:begin
wrinx($3ce,13,bank shr 1);
x:=port[$3cc] and $df;
if odd(bank) then inc(x,32);
port[$3c2]:=x;
end;
__aheadB:wrinx($3ce,13,bank*17);
__ncr:wrinx($3c4,$18,bank shl 2);
__vesa:begin
rp.bx:=0;
rp.dx:=bank*longint(64) div vgran;
vio($4f05);
rp.bx:=1;
vio($4f05);
end;
end;
curbank:=bank;
end;
procedure setpix(x,y,col:word);
var l:longint;
begin
l:=y*bytes+x;
setbank(l shr 16);
mem[vseg:word(l)]:=col;
end;
procedure setvesa(bx:word);
var vesarec:array[0..255] of byte;
begin
rp.bx:=bx;
vio($4f02);
rp.cx:=bx;
rp.es:=sseg;
rp.di:=ofs(vesarec);
vio($4f01);
vgran:=vesarec[4];
end;
procedure setchip(mde:word);
begin
vio(mde);
portw[$46e8]:=$1e;
portw[$103]:=$80;
portw[$46e8]:=$e;
modinx(base+2,4,4,4);
modinx(base+2,11,3,1);
end;
procedure setev(mde:word);
begin
rp.bl:=mde;
vio($70);
end;
procedure setwd(mde:word);
begin
vio(mde);
modinx($3ce,15,$17,5);
wrinx(base,$29,$85);
modinx(base,$2f,2,0);
end;
procedure setvideo(mde:word);
begin
rp.bl:=mde;
vio($6f05);
end;
procedure setmode0; {Enter 320x200 mode}
begin
bytes:=320;lins:=200;
case CHIP of
__chips451,__chips452,__chips453:setchip($13);
__paradise:setwd($13);
else vio($13);
end;
end;
procedure setmode1; {Enter 640x400 mode}
begin
bytes:=640;lins:=400;
case CHIP of
__chips451,__chips452,__chips453:setchip($78);
__paradise:setwd($5e);
__video7:setvideo($66);
__tseng3:begin vio($2d);lins:=350 end;
__tseng4:vio($2f);
__tridBR,__tridCS,__poach,__trid89:vio($5c);
__everex:setev($14);
__ati1,__ati2:vio($61);
__genoa:vio($7e);
__oak:;
__cirrus:;
__aheadA,__aheadB:vio($60);
__ncr:;
__vesa:setvesa($100);
end;
end;
procedure setmode2; {Enter 640x480 mode}
begin
bytes:=640;lins:=480;
case CHIP of
__chips451,__chips452,__chips453:setchip($79);
__paradise:setwd($5f);
__video7:setvideo($67);
__tseng3,__tseng4:vio($2e);
__tridBR,__tridCS,__poach,__trid89:vio($5d);
__everex:setev($30);
__ati1,__ati2:vio($62);
__genoa:vio($5c);
__oak:vio($53);
__cirrus:;
__aheadA,__aheadB:vio($61);
__ncr:;
__vesa:setvesa($101);
end;
end;
procedure setmode3; {Enter 800x600 mode}
begin
bytes:=800;lins:=600;
case CHIP of
__chips451,__chips452,__chips453:setchip($7b);
__paradise:setwd($5c);
__video7:setvideo($69);
__tseng3,__tseng4:vio($30);
__tridBR:;
__tridCS,__poach,__trid89:vio($5e);
__everex:setev($31);
__ati1,__ati2:vio($63);
__genoa:vio($5e);
__oak:vio($54);
__cirrus:;
__aheadA,__aheadB:vio($61);
__ncr:;
__vesa:setvesa($101);
end;
end;
procedure setmode4; {Enter 1024x768 mode}
begin
bytes:=1024;lins:=768;
case CHIP of
__tseng4:vio($38);
__tridCS,__trid89:vio($61);
__everex:setev($32);
__ati2:vio($61);
__aheadB:vio($63);
__vesa:setvesa($105);
end;
end;
procedure setvstart(l:longint); {Set the display start address}
var x,y:word;
begin
x:=l shr 2;
y:=(l shr 18) and mmmask[mm];
wrinx(base,13,lo(x));
wrinx(base,12,hi(x));
case chip of
__tseng3:modinx(base,$23,2,y shl 1);
__tseng4:modinx(base,$33,3,y);
__tridcs:modinx(base,$1e,32,y shl 5);
__trid89:begin
modinx(base,$1e,$a0,y shl 5+128);
wrinx($3c4,11,0);
modinx($3c4,$e,1,y shr 1);
end;
__video7:modinx($3c4,$f6,$70,(y shl 4) and $30);
__paradise:modinx($3ce,$d,$18,y shl 3);
__chips452,__chips453:
begin
wrinx($3d6,12,y);
modinx($3d6,4,4,4);
end;
__aheadb:modinx($3ce,$1c,3,y);
end;
end;
procedure wrtxt(x,y:word;txt:string); {write TXT to pos (X,Y)}
type
pchar=array[char] of array[0..15] of byte;
var
p:^pchar;
c:char;
i,j,z,b:integer;
begin
rp.bh:=6;
vio($1130);
p:=ptr(rp.es,rp.bp);
for z:=1 to length(txt) do
begin
c:=txt[z];
for j:=0 to 15 do
begin
b:=p^[c][j];
for i:=x+7 downto x do
begin
if odd(b) then setpix(i,y+j,15)
else setpix(i,y+j,0);
b:=b shr 1;
end;
end;
inc(x,8);
end;
end;
procedure testvmode; {Test pattern}
begin
for x:=50 to bytes-50 do
begin
setpix(x,30,lo(x));
setpix(x,lins-30,lo(x));
end;
for x:=30 to lins-30 do
begin
setpix(x+20,x,lo(x));
setpix(bytes-30-x,x,lo(x));
setpix(50,x,lo(x));
setpix(bytes-50,x,lo(x));
end;
wrtxt(70,70,name+' with '+mems[mm]+'bytes.');
wrtxt(70,100,'Mode: '+istr(bytes)+'x'+istr(lins)+' 256 color');
if readkey=' ' then;
textmode(3);
end;
function getbios(offs,lnn:word):string;
var s:string;
begin
s[0]:=chr(lnn);
move(mem[$c000:offs],s[1],lnn);
getbios:=s;
end;
function tstrg(pt,msk:word):boolean; {Returns true if the bits in MSK
of register PT are read/writ